class_name Character

# id
var id: int
# 姓名
var name: StringName
# 年龄
var age: int
# 性别
var sex: int
# 出生日期
var birthdate: String
# ==================== 基本属性 ===========================
# HP
var max_hp: int = 1
var hp: int
# MP
var max_mp: int
var mp: int
# 体质
var physique: int
# 力量
var force: int
# 速度
var speed: int
# 智力
var intelligence: int
# 精神
var spirit: int
# 幸运
var lucky: int
# 魅力
var charm: int
# =================== 加成信息
# 物理防御
var defense: int
# 魔法防御
var mdef: int
# 攻击力
var atk: int
# 等级
var lv: int
# 总经验值
var sum_exp: int
# 当前经验
var exp: int
# 身份 玩家 怪物 npc
var type: CHARACTER_TYPE
enum CHARACTER_TYPE{
# 玩家
	PLAY,
# 怪
	MONSTER,
# npc
	NPC
}


func set_id(value: int):
	id = value
	return self


func get_id():
	return id


# 设置最大生命值
func set_max_hp(value: int) -> int:
	max_hp = value
	return max_hp


# 获取最大生命值
func get_max_hp() -> int:
	return max_hp


# 获取当前生命值
func get_hp() -> int:
	return hp


# 恢复生命值
func recover_hp(value: int) -> int:
	hp += value
	return clamp(hp, 0, max_hp)


# 减少生命值
func reduce_hp(value: int) -> int:
	hp -= value
	return clamp(hp, 0, max_hp)


# 设置最大mp
func set_max_mp(value: int) -> int:
	max_mp = value
	return max_mp


# 获取最大mp
func get_max_mp() -> int:
	return max_mp


# 恢复mp
func recover_mp(value: int) -> int:
	mp += value
	return clamp(mp, 0, max_mp)


# 减少mp
func reduce_mp(value: int) -> int:
	mp -= value
	return clamp(mp, 0, max_mp)


# 增加体质
func plus_physique(value: int) -> int:
	if value>0:
		physique += value
	return physique


# 降低体质
func minus_physique(value: int) -> int:
	if value>0:
		physique -= value
	if physique < 0:
		physique = 0
	return physique


# 获取当前体质
func get_physique() -> int:
	return physique


# 增加力量
func plus_force(value: int) -> int:
	if value>0:
		force += value
	return force


# 降低力量
func minus_force(value: int) -> int:
	if value>0:
		force -= value
	if force < 0:
		force = 0
	return force


# 获取当前力量
func get_force() -> int:
	return force


# 增加速度
func plus_speed(value: int) -> int:
	if value>0:
		speed += value
	return speed


# 降低速度
func minus_speed(value: int) -> int:
	if value>0:
		speed -= value
	if speed < 0:
		speed = 0
	return speed


# 获取当前速度
func get_speed() -> int:
	return speed


# 增加智力
func plus_intelligence(value: int) -> int:
	if value>0:
		intelligence += value
	return intelligence


# 降低智力
func minus_intelligence(value: int) -> int:
	if value>0:
		intelligence -= value
	if intelligence < 0:
		intelligence = 0
	return intelligence


# 获取当前智力
func get_intelligence() -> int:
	return intelligence


# 增加精神
func plus_spirit(value: int) -> int:
	if value>0:
		spirit += value
	return spirit


# 降低精神
func minus_spirit(value: int) -> int:
	if value>0:
		spirit -= value
	if spirit < 0:
		spirit = 0
	return spirit


# 获取当前精神
func get_spirit() -> int:
	return spirit


# 增加幸运
func plus_lucky(value: int) -> int:
	if value>0:
		lucky += value
	return lucky


# 降低幸运
func minus_lucky(value: int) -> int:
	if value>0:
		lucky -= value
	if lucky < 0:
		lucky = 0
	return lucky


# 获取当前幸运
func get_lucky() -> int:
	return lucky


# 增加精神
func plus_charm(value: int) -> int:
	if value>0:
		charm += value
	return charm


# 降低精神
func minus_charm(value: int) -> int:
	if value>0:
		charm -= value
	if charm < 0:
		charm = 0
	return charm


# 获取当前精神
func get_charm() -> int:
	return charm


# 增加物理防御
func plus_defense(value: int) -> int:
	if value>0:
		defense += value
	return defense


# 降低物理防御
func minus_defense(value: int) -> int:
	if value>0:
		defense -= value
	if defense < 0:
		defense = 0
	return defense


# 获取当前物理防御
func get_defense() -> int:
	return defense


# 增加魔法防御
func plus_mdef(value: int) -> int:
	if value>0:
		mdef += value
	return mdef


# 降低魔法防御
func minus_mdef(value: int) -> int:
	if value>0:
		mdef -= value
	if mdef < 0:
		mdef = 0
	return mdef


# 获取当前魔法防御
func get_mdef() -> int:
	return mdef


# 增加攻击力
func plus_atk(value: int) -> int:
	if value>0:
		atk += value
	return atk


# 降低攻击力
func minus_atk(value: int) -> int:
	if value>0:
		atk -= value
	if atk < 0:
		atk = 0
	return atk


# 获取当前攻击力
func get_atk() -> int:
	return atk


# 增加经验
func plus_exp(value: int) -> int:
	if value>0:
		exp += value
		sum_exp += value
	return exp


# 使用经验
func minus_exp(value: int) -> int:
	if value <= exp and exp>=0:
		exp -= value
	return exp


# 获取当前经验
func get_exp() -> int:
	return exp


# 获取总经验
func get_sum_exp() -> int:
	return sum_exp


#对象转字典
func obj_to_dic() ->Dictionary:
	var dic: Dictionary = Dictionary()
	dic["id"] = self.id
	dic["name"] = self.name
	dic["age"] = self.age
	dic["sex"] = self.sex
	dic["birthdate"] = self.birthdate
	dic["max_hp"] = self.max_hp
	dic["hp"] = self.hp
	dic["max_mp"] = self.max_mp
	dic["mp"] = self.mp
	dic["physique"] = self.physique
	dic["force"] = self.force
	dic["speed"] = self.speed
	dic["intelligence"] = self.intelligence
	dic["spirit"] = self.spirit
	dic["lucky"] = self.lucky
	dic["charm"] = self.charm
	dic["defense"] = self.defense
	dic["mdef"] = self.mdef
	dic["atk"] = self.atk
	dic["lv"] = self.lv
	dic["sum_exp"] = self.sum_exp
	dic["exp"] = self.exp
	return dic


func _to_string():
	return "{id = %s,name = %s,age = %s,sex = %s,birthdate = %s,max_hp = %s,hp = %s,max_mp = %s,mp = %s,physique = %s,force = %s,speed = %s,intelligence = %s,spirit = %s,lucky = %s,charm = %s,defense = %s,mdef = %s,atk = %s,lv = %s,sum_exp = %s,exp = %s,type = %s}" % [self.id, self.name, self.age, self.sex, self.birthdate, self.max_hp, self.hp, self.max_mp, self.mp, self.physique, self.force, self.speed, self.intelligence, self.spirit, self.lucky, self.charm, self.defense, self.mdef, self.atk, self.lv, self.sum_exp, self.exp,self.type]


	
